package server.performance;

import iface.Envelope;
import iface.Location;
import iface.Logger;
import iface.MessageInterface;
import iface.Status;

import java.util.List;
import java.util.TimerTask;

public class SendLocations extends TimerTask {
    private List<String> users;
    private int lng = 0;
    private int lat = 0;
    
    public SendLocations(List<String> users) {
        this.users = users;
    }
    
    public void run() {
        Envelope env;
        Location loc;
        for (String user : users) {
            loc = new Location(user, lng, lat);
            env = new Envelope(user, loc);
            Status status = MessageInterface.sendEnvelopeToServer(env);
            if (status.getMessageStatus().equals(Status.Result.SUCCESS))
                Logger.log(status.getLocationList().toString());
            else
                Logger.error("Did not recieve location list");
        }
        lng++;
        lat++;
    }
}